/**
 * 作者：陈文斌 on 2019/1/23.
 * 邮箱：chen_wennbin@163.com
 * 版本：v1.0
 */

import 'package:flutter/material.dart';
import 'package:crm/constant/constant.dart';
import 'package:crm/view/Tile/tile_normal.dart';
import 'package:crm/view/Tile/list_tile_text_field.dart';
import 'package:crm/view/Tile/list_tile_text.dart';
import 'package:crm/view/GridView/grid_view_add_image.dart';
import 'package:flutter_datetime_picker/flutter_datetime_picker.dart';
import 'package:crm/tools/date_format_util.dart';
import 'package:crm/view/AppBar/custom_app_bar.dart';

const String Title = '添加用户反馈';

class AddFeedbackRecordPage extends StatefulWidget {
  final String customerId;
  final String customerName;

  AddFeedbackRecordPage({
    Key key,
    this.customerId,
    this.customerName,
  }) : super(key: key);

  @override
  State<StatefulWidget> createState() {
    return _AddFeedbackRecordPageState();
  }
}

class _AddFeedbackRecordPageState extends State<AddFeedbackRecordPage> {
  String _customerId;
  String _feedbackDate = DateFormatUtil.getDateStrByDateTime(DateTime.now(),
      format: DateFormat.YEAR_MONTH_DAY);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: CustomAppBar(
        title: Title,
      ),
      body: SafeArea(
        child: GestureDetector(
          behavior: HitTestBehavior.translucent,
          onTap: () {
            FocusScope.of(context).requestFocus(FocusNode());
          },
          child: ListView(
            children: <Widget>[
              Padding(padding: EdgeInsets.only(top: 10)),
              ListTileText(
                onTap: () {},
                title: Text(
                  '反馈公司',
                  style: TextStyle(
                    color: AppColors.DetailTextColor,
                    fontSize: AppFontSizes.Font15,
                    fontFamily: AppFontFamilies.PingFangSC,
                    fontWeight: FontWeight.w500,
                  ),
                ),
                content: widget.customerName ?? '',
                requiredVisible: false,
              ),
              ListTileText(
                onTap: () {
                  DatePicker.showDatePicker(
                    context,
                    showTitleActions: true,
                    minTime: DateTime(1997, 01, 01),
                    maxTime: DateTime.now(),
                    onConfirm: (date) {
                      print(
                          'confirm ${DateFormatUtil.getDateStrByDateTime(date, format: DateFormat.YEAR_MONTH_DAY)}');
                      _feedbackDate = DateFormatUtil.getDateStrByDateTime(date,
                          format: DateFormat.YEAR_MONTH_DAY);
                      setState(() {});
                    },
                    currentTime: DateTime.now(),
                    locale: LocaleType.zh,
                  );
                },
                title: Text(
                  '反馈时间',
                  style: TextStyle(
                    color: AppColors.DetailTextColor,
                    fontSize: AppFontSizes.Font15,
                    fontFamily: AppFontFamilies.PingFangSC,
                    fontWeight: FontWeight.w500,
                  ),
                ),
                content: _feedbackDate ?? '',
                requiredVisible: false,
                dividerVisible: true,
              ),
              TileNormal(
                title: Text(
                  '反馈信息',
                  style: TextStyle(
                    color: AppColors.DetailTextColor,
                    fontSize: AppFontSizes.Font15,
                    fontFamily: AppFontFamilies.PingFangSC,
                    fontWeight: FontWeight.w500,
                  ),
                ),
                height: 42,
              ),
              Container(
                color: Colors.white,
                padding: EdgeInsets.fromLTRB(16, 13, 16, 13),
                child: Column(
                  children: <Widget>[
                    TextField(
                      onChanged: (str) {},
                      decoration: InputDecoration(
                        hintText: '请输入…',
                        hintStyle: TextStyle(
                          color: AppColors.PlaceholderTextColor,
                          fontSize: AppFontSizes.Font13,
                          fontFamily: AppFontFamilies.PingFangSC,
                          fontWeight: FontWeight.w500,
                        ),
                        border: InputBorder.none,
                        contentPadding: EdgeInsets.zero,
                      ),
                      style: TextStyle(
                        color: AppColors.TextColor,
                        fontSize: AppFontSizes.Font13,
                        fontFamily: AppFontFamilies.PingFangSC,
                        fontWeight: FontWeight.w500,
                      ),
                      maxLines: 5,
                    ),
                    Padding(padding: EdgeInsets.only(top: 25)),
                    GridViewAddImage(
                      contentPadding: EdgeInsets.zero,
                    )
                  ],
                ),
              ),
              Padding(padding: EdgeInsets.only(top: 10)),
              ListTileTextField(
                title: Text(
                  '受理人',
                  style: TextStyle(
                    color: AppColors.DetailTextColor,
                    fontSize: AppFontSizes.Font15,
                    fontFamily: AppFontFamilies.PingFangSC,
                    fontWeight: FontWeight.w500,
                  ),
                ),
                content: '',
                hintText: '必填',
              ),
              Container(
                height: 40,
                margin: EdgeInsets.fromLTRB(
                  AppScreen.setWidth(29),
                  120,
                  AppScreen.setWidth(29),
                  35,
                ),
                decoration: BoxDecoration(
                  color: AppColors.MainColor,
                  borderRadius: BorderRadius.circular(20),
                ),
                child: ClipRRect(
                  borderRadius: BorderRadius.circular(20),
                  child: MaterialButton(
                    onPressed: () {
                      print('111');
                    },
                    child: Text(
                      '完成',
                      style: TextStyle(
                        color: Colors.white,
                        fontSize: AppFontSizes.Font17,
                        fontFamily: AppFontFamilies.PingFangSC,
                        fontWeight: FontWeight.w500,
                      ),
                    ),
                  ),
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
